package excessoes;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 *
 * @author Marcelo Gomes Neto
 */
public class RNException extends Exception 
{
    private static final long serialVersionUID = 7466975956354668504L;
    public static final String erro = "erro";  
    public static final String info = "info";  
    public static final String alert = "alert";  
    public static final String criticalError = "criticalErro"; 

    /**
     * Creates a new instance of
     * <code>RNException</code> without detail message.
     */
    public RNException() {
    }

    /**
     * Constructs an instance of
     * <code>RNException</code> with the specified detail message.
     *
     * @param msg the detail message.
     */
    public RNException(String msg, String tipo) 
    {
        //super(msg);
        if (tipo.equalsIgnoreCase("erro")) {  
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));  
        }  
        if (tipo.equalsIgnoreCase("info")) {  
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, null));  
        }  
        if (tipo.equalsIgnoreCase("alert")) { 
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, msg, null));  
        }  
        if (tipo.equalsIgnoreCase("criticalErro")) {  
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, msg, null));  
        }  
    }
}
 
  

